//
//  VisitorController.swift
//  WeiBo001
//
//  Created by ZhiQiang Li on 16/7/19.
//  Copyright © 2016年 ZhiQiang Li. All rights reserved.
//

import UIKit

class VisitorController: UIViewController {
    //判断用户是否登录
    var isLogin: Bool = CZUserAccountViewModel.sharedTools.isLogin
    //访客视图
    var visitorV : VisitorView?
    

    //监听放法
    @objc private func loginClick(){
    let OauthVC = OauthViewController()
        
        presentViewController(UINavigationController(rootViewController: OauthVC), animated: true, completion: nil)
    }
    override func loadView() {
        isLogin ? (view = tableView ) : setupVisitorView()
    }
    
    //设置访客视图
    func setupVisitorView(){
        visitorV = VisitorView()
        visitorV?.closure = {[weak self] in
        self?.loginClick()
            
        }
        view = visitorV
        setupNav()
        
    }


       //设置导航按钮
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "registerButtonClick")
                  }
   override func viewDidLoad() {
        super.viewDidLoad()
        
    }

//懒加载
  lazy var tableView: UITableView = UITableView()
    
}
